package com.cashmama.market.api.application.controller.user.request;

import com.cashmama.market.api.infras.utils.ParamsValidateUtil;
import com.cashmama.market.api.infras.utils.StringUtils;
import com.fqgj.common.api.ParamsObject;
import com.fqgj.common.utils.PasswordUtil;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-03-17 22:20
 **/
public class UserPasswordResetRequest extends ParamsObject {

    /**
     * 手机号
     */
    private String mobile;
    /**
     * 验证码
     */
    private String verifycode;
    /**
     * 密码
     */
    private String password;

    public String getMobile() {
        return mobile;
    }

    public UserPasswordResetRequest setMobile(String mobile) {
        this.mobile = mobile;
        return this;
    }

    public String getVerifycode() {
        return verifycode;
    }

    public UserPasswordResetRequest setVerifycode(String verifycode) {
        this.verifycode = verifycode;
        return this;
    }

    public String getPassword() {
        return password;
    }

    public UserPasswordResetRequest setPassword(String password) {
        this.password = password;
        return this;
    }

    @Override
    public void validate() {
        ParamsValidateUtil.checkParams(StringUtils.isEmpty(mobile), "mobile can not be empty");
        ParamsValidateUtil.checkParams(StringUtils.isEmpty(verifycode), "verifycode can not be empty");
        ParamsValidateUtil.checkParams(StringUtils.isEmpty(password), "password can not be empty");
        ParamsValidateUtil.checkParams(!PasswordUtil.isPasswordValidate(password), "The password is illegal");
    }
}
